#ifndef _AppInfoWin_h_
#define _AppInfoWin_h_

/*
  App Info window (copied from About window)
*/
#include "PowerWindow.h" // Contains TopWindow

// My creation:  Allows easier cloning of window pages
#undef WINNAME
#define WINNAME AppInfoWin

// U++ connection
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

//============================================================================================================================
class AppInfoWin : public WithAppInfoLayout<PowerWindow> {

public:

	typedef AppInfoWin CLASSNAME;

	//============================================================================================================================
	AppInfoWin() {
		TIMING(String().Cat() << "Creating " << QUOTEME(WINNAME));
		// Following must be in constructor or will abort on 2nd open
		CtrlLayout(*this);
	}
	
	//============================================================================================================================
	~AppInfoWin() {
		RTIMING(String().Cat() << "Destroying " QUOTEME(WINNAME));
	}
	
	//============================================================================================================================
	virtual void Close() {
		// Serialize, mostly position information
		PowerWindow::Close("appinfo");  // Make sure to call PowerWindow close and not directly call TopWindow or else configuration is not saved possibly until application closes
	}

	//============================================================================================================================
	virtual void Xmlize(XmlIO xml) {
		
	}
	
	//============================================================================================================================
	void Open() {
		
		String commandLineAsString;
		this->Sizeable(true).Zoomable(true);  // May want to lengthen so they can see the full long paths.
		// EditField looks best.  LineEdit doesn't let you select text and the font is hosed.
		appPath.SetData(GetExeFilePath()); 
		appPath.Tip(GetExeFilePath());
		userPath.SetData(GetHomeDirectory()); 
		userPath.Tip(GetHomeDirectory());
		// Track donation history to make sure adequately supporting development of included apps
		// Donate $20 via paypal 2/12/10 due to excellent quality of U++ application, support, performance, GridCtrl
		ideDonations.SetData("$20 @ 2/12/10 via PayPal");
		String _compilerLog = 
			"[0 " // begin 6 point font
			"This object: Compiled as "
			;

		// Microsoft C++ Predefined Macros
		// _WIN32 _WIN64  __TIMESTAMP__
		
		//  To ensure that the full path to the file is displayed, use /FC (Full Path of Source Code File in Diagnostics).
		#define WIDEN2(x) L ## x
		#define WIDEN(x) WIDEN2(x)
		#define __WFILE__ WIDEN(__FILE__)
		wchar_t *pwsz = (wchar_t *)__WFILE__;

		#ifdef DEBUG
		_compilerLog+= "DEBUG ";
		#endif
		
		#ifdef RELEASE
		_compilerLog+= "RELEASE ";
		#endif
			
		#ifdef _DEBUG
		_compilerLog+= "(MSC) `/LDd, `/MDd, and `/MTd ";
		#endif
		_compilerLog+=
			"Core [^http://www.ultimatepp.org/index.html^ U`+`+] system is v1952.  All compiles are MT.&"
			"As of 2010`\02`\12 - Compiled [@G successfully] with Visual Studio 2010.&" // & is paragraph
			"Microsoft (R) 32-bit C/C`+`+ Optimizing Compiler Version 15.00.30729.01 for 80x86&" // ` is escape
			"&"
			"Attempt to compile with [_ MinGW] 3.4.5 and 4.4.1 [@R failed]&" // font RED the word failed
			"3.4.5 Debug MT gave this error in Draw code:&"
			" something to do with `_`_thread for local storage&"
			"4.4.1 from TDM ([^http://www.tdragon.net/recentgcc/^ Twilight Dragon Media])&"
			"Gave all errors on project_shared.h and .cpp&"
			" - error: project.iml: No such file or directory&"
			" - warning: unknown escape sequence '`\\,'&"
			" - error: invalid initialization of non-const reference of type 'Timer`&' from a temporary of type 'Timer'&"
			;
		#ifdef _INTEGRAL_MAX_BITS
		_compilerLog+= Format("Integral max bits = %d&", _INTEGRAL_MAX_BITS);
		#endif
		
		#ifdef _CPPRTTI
		_compilerLog+= "Run-Time Type Information (`/GR)&";
		#endif
		
		#ifdef _M_IX86
		switch (_M_IX86) {
			case 600:
				_compilerLog+= "Compiled for Blend or Pentium Pro, Pentium II`/III (`/GB or `/G6) ";
				break;
			case 500:
				_compilerLog+= "Compiled for Pentium (`/G5) ";
				break;
			case 300:
				_compilerLog+= "Compiled for 386 (`/G3) ";
				break;
			case 400:
				_compilerLog+= "Compiled for 486 (`/G4) ";
				break;
			default:
				_compilerLog+= Format("Compiled for x86 processor: %d&", _M_IX86);
				break;
		}
		#endif
		
		#ifdef _CPPLIB_VER
		_compilerLog+= Format("Dinkumware header files version: %d&", _CPPLIB_VER);
		#endif
		
		#ifdef _CPPUNWIND
		_compilerLog+= "Exception Handling Enabled (`/GX)&";
		#endif
		
		#ifdef _M_X64
		_compilerLog+= Format("x64 processor: %d&", _M_X64);
		#endif
		  
		#ifdef _MSC_EXTENSIONS
		_compilerLog+= Format("MSC Extensions (Deprecated) (`/Ze): %d&", _MSC_EXTENSIONS);
		#endif
		
		#ifdef __MSVC_RUNTIME_CHECKS
		_compilerLog+= Format("MSVC Runtime checks enables (`/RTC option: %d)&", __MSVC_RUNTIME_CHECKS);
		#endif
		
		#ifdef _MSDOS
		_compilerLog+= "Targeting MSDOS&";
		#endif
		
		#ifdef _M_I86TM
		_compilerLog+= "16-bit Tiny model ";
		#endif
		
		#ifdef _M_I86SM
		_compilerLog+= "16-bit Small model ";
		#endif
		
		#ifdef _M_I86MM
		_compilerLog+= "16-bit Medium model ";
		#endif
		
		#ifdef _M_I86LM
		_compilerLog+= "16-bit Large model ";
		#endif
		
		#ifdef _M_I86HM
		_compilerLog+= "16-bit Huge model ";
		#endif

		#ifdef _M_I8086
		_compilerLog+= "8088 or 8086 (`/G0)";
		#endif
		
		#ifdef _M_I286
		_compilerLog+= "80286 (`/G1 or `/G2)";
		#endif
		
		#ifdef _MSC_VER

		switch (_MSC_VER) {
			case 600:
	 			_compilerLog+= "C Compiler version 6.0. ver 600.";
	 			break;
	 		case 700:
   				_compilerLog+= "C/C`+`+ compiler version 7.0 ver 700.";
   				break;
   			case 800:
   				_compilerLog+= "Visual C`+`+, 32-bit, (MSVC`+`+ 1.0) ver 800.";
   				break;
   			case 900:
   				_compilerLog+= "Visual C`+`+, Windows, (MSVC`+`+ 2.0) ver 900.";
   				break;
   			case 1000:
   				_compilerLog+= "Visual C`+`+, 32-bit, (MSVC`+`+ 2.x) or Visual C`+`+ 32-bit (MSVC`+`+ 4.0) ver 1000.";
   				break;
   			case 1020:
   				_compilerLog+= "Visual C`+`+, 32-bit, Visual C`+`+ 32-bit (MSVC`+`+ 4.2) ver 1020.";
   				break;
   			case 1100:
   				_compilerLog+= "Visual C`+`+, 32-bit, (MSVC`+`+ 5.0) ver 1100.";
   				break;
   			case 1200:
   				_compilerLog+= "Visual C`+`+, 32-bit, (MSVC`+`+ 6.0) ver 1200.";
   				break;
			case 1300:
				_compilerLog+= "Microsoft Visual C`+`+ .NET 2003 (MSVC`+`+ 7.0) ver 1300.";
				break;
			case 1310:
				_compilerLog+= "Microsoft Visual C`+`+ .NET 2003 (MSVC`+`+ 7.1) ver 1310.";
				break;
			case 1400:
				_compilerLog+= "Visual C`+`+ Compiler (MSVC`+`+ 8.0) ver 1400.";
				break;
			case 1500:
				_compilerLog+= "Visual Studio 2008 (MSVC`+`+ 9.0) ver 1500.";
				break;
			case 1600:
				_compilerLog+= "Visual Studio 2010 (MSVC`+`+ 10.0) ver 1600.";
				break;
			default:
				_compilerLog+= Format("Compiler: %d. ", _MSC_VER);
				break;
		}
		#endif
		
		// _MSC_BUILD
		
		#ifdef _MSC_FULL_VER
		_compilerLog+= Format("&MSC Full Version. Major, minor, and build number. %d&", _MSC_FULL_VER);
		#endif
		
		#ifdef _M_I86_FP
		
		switch (_M_I86_FP) {
			case 0:
				_compilerLog+= "`/arch not used. ";
				break;
			case 1:
				_compilerLog+= "`/arch:SSE was used. ");
				break;
			case 2:
				_compilerLog+= "`/arch:SSE2 was used. ";
				break;
			default:
				_compilerLog+= Format("`/arch option: %d. ", _M_I86_FP);
				break;
		}
		#endif

		#ifdef __WATCOMC__
		_compilerLog+= "Watcom ";
		#endif
		
		#ifdef __USLC__
		_compilerLog+= "USL C ";
		#endif
		
		#ifdef _UCC
		_compilerLog+= "Ultimate C`/C`+`+ ";
		#endif
		
		#ifdef __TINYC__
		_compilerLog+= "Tiny C ";
		#endif
		
		#ifdef __TenDRA__
		_compilerLog+= "TenDRA C`/C`+`+ ";
		#endif
		
		#ifdef __SUNPRO_C
		_compilerLog+= "Sun Studio ";
		#endif
		
		#ifdef __SUNPRO_CC
		_compilerLog+= "Sun Studio CC ";
		#endif
		
		#ifdef SDCC
		_compilerLog+= "Small Device C Compiler ";
		#endif
		
		#ifdef _SCO_DS
		_compilerLog+= "SCO OpenServer";
		#endif
		
		#ifdef __MINGW23__
		_compilerLog+= Format("MinGW version %s&", __MINGW32__);
		#endif
		
		#ifdef __INTEL_COMPILER
		_compilerLog+= Format("MinGW version %s&", __INTEL_COMPILER);
		#endif
		
		#ifdef __GNUC__
		_compilerLog+= Format("GNU C`/C`+`+ %s&", __GNUC__);
		#endif

		_compilerLog+= "]"; // end main font

		compilerLog.SetData(_compilerLog);
		
		const Vector<String>& arg = CommandLine();
		String cm = Join(arg, " ");

		// Show command-line arguments

		commandLine.SetData(cm);
		
		// C:\MyApps\external libraries\Static Debug\libwmp3d.lib
		// Link to wmp3d home
		// Show calling user
		// List attached xml files
		// Let user make an annotation
		// Show exe size, cpu usage
		// Show paths to support
		// List system keys assigned
		// View log file, browse directory
		// To use C++ String wrapping feature, you must construct a string
		
		String lic =
			"[0 DISCLAIMER&&"
			"This program is distributed as freeware. This software is provided \"as is\", without any guarantee "
			"made as to its suitability or fitness for any particular use`. It may contain bugs`, "
			"so use of this tool is at your own risk`. Author takes no responsibility for any damage that may unintentionally "
			"be caused through its use`.&"
			"&License`:&&"
			"This program is free software`; you can redistribute it and`/or modify it under the "
			"terms of the GNU General Public License as published by the Free Software Foundation`; either version "
			"2 of the License, or (at your option) any later version. This program is distributed in the hope that it "
			"will be useful`, but WITHOUT ANY WARRANTY`; without even the implied warranty of MERCHANTABILITY or FITNESS "
			"FOR A PARTICULAR PURPOSE`. See the GNU General Public License for more details`.&"
			"]";
		MP3License.SetData(lic);
		mp3SourceURL.SetData("[1l20b20^http://www.inet.hr/~zcindori/libwmp3/index.html^ \1http://www.inet.hr/~zcindori/libwmp3/index.html"); // Don't escape the slashes and stuff since its a url
		decoderSourceURL.SetData("[1l20b20^http://www.underbit.com/products/mad/^ \1http://www.underbit.com/products/mad/");
		decoderSourceURL.Tip(
		  "MAD is a high-quality MPEG audio decoder. It currently supports MPEG-1 and the MPEG-2 extension to lower sampling frequencies, as well as the de facto MPEG 2.5 format. All three audio layers — Layer I, Layer II, and Layer III (i.e. MP3) — are fully implemented.&"
		  "MAD does not yet support MPEG-2 multichannel audio (although it should be backward compatible with such streams) nor does it currently support AAC.&"
		  );
		//24-bit PCM output
		//100% fixed-point (integer) computation
		//completely new implementation based on the ISO/IEC standards
		//available under the terms of the GNU General Public License (GPL)
		equalizerSourceURL.SetData("[1l20b20^http://shibatch.sourceforge.net/^ \1http://shibatch.sourceforge.net/");
		equalizerSourceURL.Tip("An accurate equalizer for winamp 2(yes, it's old). It uses FIR filter with 16383 taps, which is substantially longer than other equalizers. Although it has many knobs to change frequency characteristics, it does not degrade audio quality.");

		PowerWindow::Open("appinfowin"); // Loads user's window position

	}
};

#endif

